#include <iostream>
#include "shell.h"

#include <filesystem>

#include "command.h"

int shell::run() {
	std::cout << std::unitbuf;
	std::cerr << std::unitbuf;

	// Uncomment this block to pass the first stage


	std::string input;
	int result_code{0};
	bool flag = true;
	while(flag) {
		std::cout << "$ ";
		std::getline(std::cin, input);
		command command(input);
		auto [result_code, data] = command.run();
		if(commands_enum::EXIT == command.type) {
			flag = false;
		}
		if(0 == result_code && not data.empty())
			std::cout << data;
		else
			std::cerr << data;
		input.clear();
	}
	return result_code;
}
